package com.bobi.tfca.model.entity;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bobi.tfca.model.enums.AuditStatusEnum;
import com.bobi.tfca.model.vo.AuditVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 审核实体
 *
 * @author 李文发
 * @date 2024/4/2
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "audit")
public class AuditEntity {

    @TableId
    @ApiModelProperty(value = "审核id")
    // 审核id
    private Integer auditId;
    @ApiModelProperty(value = "类型")
    // 类型
    private Integer category;
    @ApiModelProperty(value = "具体类别")
    // 具体类别
    private Integer subType;
    @ApiModelProperty(value = "申请时间")
    // 申请时间
    private LocalDateTime applyTime;
    @ApiModelProperty(value = "具体项id")
    // 具体项id
    private Integer itemId;
    @ApiModelProperty(value = "审核者id")
    // 审核者id
    private Integer auditorId;
    @ApiModelProperty(value = "是否通过（0：未通过，1：通过）")
    // 是否通过（0：未审核，1：未通过，2：通过）
    private Integer auditStatus;

    public static AuditEntity ofAuditVO(AuditVO auditVO) {
        AuditEntity entity = BeanUtil.copyProperties(auditVO, AuditEntity.class, "pass");
        AuditStatusEnum status = AuditStatusEnum.getStatusByDesc(auditVO.getAuditStatus());
        entity.setAuditStatus(status.getCode());
        return entity;
    }
}
